﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using JT_DBMgr;
using Pub;

namespace LZQXT.Test
{
    /*
    public class CTree
    {


        private ADOTest ado1;

        public void fillTreeView(TreeView tv1, TreeNodeDBMgr node1)
        {
            try
            {
                ado1 = fdb_tree.ado1;

                string PreID = "";
                if (node1 != null) PreID = node1.Tag.ToString();
                if (PreID == string.Empty) PreID = node1.sRootID;
                string strSQL = "SELECT * FROM " + node1.sTabName
                    + " WHERE " + node1.sPreCol + "=" + PreID + " Order By " + node1.sOrderID;
                //CDebug.Send(strSQL);
                ado1.sel1(strSQL);
                foreach (DataRow dr in ado1.ds.Tables[0].Rows)
                {
                    TreeNodeDBMgr newNode = new TreeNodeDBMgr();

                    newNode.sRootID = node1.sRootID;
                    newNode.sTabName = node1.sTabName;
                    newNode.sPreCol = node1.sPreCol;
                    newNode.sOrderID = node1.sOrderID;
                    newNode.sName = node1.sName;
                    newNode.sTagID = node1.sTagID;
                    newNode.dbInf = node1.dbInf;
                    newNode.sIDCol = node1.sIDCol;
                    newNode.sTabDataNameS = node1.sTabDataNameS;
                    newNode.sTabDataIDS = node1.sTabDataIDS;

                    newNode.Text = dr[node1.sName].ToString();
                    newNode.Tag = dr[node1.sIDCol].ToString();
                    newNode.Target = dr[node1.sTagID].ToString();
                    newNode.ImageIndex = 0;
                    newNode.SelectedImageIndex = 0;
                    newNode.PreID = PreID;
                    newNode.dbInf = node1.dbInf;
                    newNode.i_Typ = 1;
                    //newNode.Target = "iframeCenter";
                    //newNode.NavigateUrl = "../" + dr["Url"].ToString() + "?ClsID=" + newNode.Value;

                    string sID = dr[node1.sIDCol].ToString();
                    fillTreeView(tv1, newNode);
                    if (newNode.Nodes.Count > 0)
                        newNode.ImageIndex = 0;
                    else
                        newNode.ImageIndex = 1;

                    if (node1 == null) tv1.Nodes.Add(newNode);
                    else node1.Nodes.Add(newNode);
                }
            }
            catch (System.Exception ex)
            {
                CDebug.SendError(ex.ToString());
                CDebug.Send("生成树目录", ex.ToString());
            }

        }

        public void fillMenu(ToolStripMenuItem menu1, ToolStripMenuItemII item)
        {
            ado1 = CDBMgr.fdb_tree.ado1;

            string PreID = "";
            if (item != null) PreID = item.Tag.ToString();
            if (PreID == string.Empty) PreID = item.sRootID;
            string strSQL = "SELECT * FROM " + item.sTabName
                + " WHERE " + item.sPreCol + "=" + PreID + " Order By " + item.sOrderID;
            DataSet ds1 = ado1.sel1(strSQL);
            //Pub.bugMsbox("RootID=" + RootID.ToString() + " And ds_count=" + ado1.ds_count.ToString());

            foreach (DataRow dr in ds1.Tables[0].Rows)
            {
                ToolStripMenuItemII menu_Temp = new ToolStripMenuItemII();
                string Lab = dr[item.sName].ToString();
                string ID = dr[item.sIDCol].ToString();
                menu_Temp.Text = Lab;
                menu_Temp.Tag = ID;
                menu_Temp.ID = ID;
                menu_Temp.sLab = Lab;
                menu_Temp.sTit = "";
                menu_Temp.ImageIndex = 0;
                menu_Temp.typ = ToolStripMenuItemII.TYP_LAB;
                menu_Temp.sTabName = item.sTabName;
                menu_Temp.sRootID = ID;
                menu_Temp.sPreCol = item.sPreCol;
                menu_Temp.sIDCol = item.sIDCol;
                menu_Temp.sName = item.sName;
                menu_Temp.sOrderID = item.sOrderID;

                fillMenu(null, menu_Temp);

                item.DropDownItems.Add(menu_Temp);

            }

            if (menu1 != null)
            {
                menu1.DropDownItems.Add(item);
            }

        }
    }
    */
    public class TreeNodeDBMgr : TreeNode
    {
        public String sIDCol = "ID";
        public String sName = "ClassName";
        public String sPreCol = "PreID";
        public String sTabName = "GSMA_P_Class";
        public String sTagID = "Target";
        public String sOrderID = "OrderID";
        public String sRootID = "-1";

        public String sTabDataNameS = "";
        public String sTabDataIDS = "";

        public String Target = "";
        public String PreID = "";
        public int i_Typ = 0;
        public CDB.DBInfo dbInf = null;

        public TreeNodeDBMgr() {
            dbInf = new CDB.DBInfo();
        }
    }

    public class ToolStripMenuItemII : ToolStripMenuItem
    {
        public const int TYP_LAB = 0;
        public const int TYP_TIT = 1;
        public const int TYP_DAT = 2;

        public int typ = TYP_LAB;
        public string RootID;
        public string ID;
        public string sLab;
        public string sTit;
        public String sIDCol = "ID";
        public String sName = "ClassName";
        public String sPreCol = "PreID";
        public String sTabName = "GSMA_P_Class";
        public String sTagID = "Target";
        public String sOrderID = "OrderID";
        public String sRootID = "-1";
    }
}